import 'package:flutter/material.dart';

//ListView列表组件
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('层叠布局 -Stack Positioned'),
          backgroundColor: Colors.pink[100],
        ),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    //Row组件
    return Container(
      width: 400,
      height: 300,
      decoration: BoxDecoration(
        color: Colors.pink,
        border: Border.all(color: const Color.fromARGB(255, 0, 0, 0), width: 1),
      ),
      child: Stack( //相对于外部容器定位  如果没有外部容器，则相对于屏幕定位
        children: [
          Positioned(
            left: 10,
            bottom: 10,
            child: Container(width: 100, height: 100, color: Colors.yellow),
          ),
          Positioned(child: Text('你好，牛哞哞'), right: 0, top: 150),
        ],
      ),
    );
  }
}
